package cn.jeefast.modules.platform.service.impl;

import cn.jeefast.common.entity.MbResearchStepDataTemplateObjectiveIndicators;
import cn.jeefast.common.utils.R;
import cn.jeefast.modules.platform.dao.MbResearchStepDataTemplateObjectiveIndicators1Dao;
import cn.jeefast.modules.platform.service.MbResearchStepDataTemplateObjectiveIndicators1Service;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author theodo
 * @since 2020-01-06
 */
@Service
public class MbResearchStepDataTemplateObjectiveIndicators1ServiceImpl extends ServiceImpl<MbResearchStepDataTemplateObjectiveIndicators1Dao, MbResearchStepDataTemplateObjectiveIndicators> implements MbResearchStepDataTemplateObjectiveIndicators1Service {

    @Autowired
    private MbResearchStepDataTemplateObjectiveIndicators1Dao researchStepDataTemplateObjectiveIndicatorsDao;

    @Override
    public R addOrUpdate(List<MbResearchStepDataTemplateObjectiveIndicators> list) {
        if (list.size()!=0){
            if(list.get(0).getOiId()!=null){
                //批量更新
                for (MbResearchStepDataTemplateObjectiveIndicators mrsdta:list) {
                    researchStepDataTemplateObjectiveIndicatorsDao.updateById(mrsdta);
                }
            }else{
                //批量插入
                for (MbResearchStepDataTemplateObjectiveIndicators mrsdta:list) {
                    researchStepDataTemplateObjectiveIndicatorsDao.insert(mrsdta);
                }
            }
        }
        return R.ok();
    }
}
